<?php
class SettingSaveReturnAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}
	
	protected function afterConstruct()
	{
		$this->parseDtds('return','setting');
	}
	
	public function execute()
	{
		$data = $this->getValidData();
		if($data['rate']+$data['share_rate']>90)
		{
			$this->data['error_messages']['rate'] = array('error'=>'返利比例与分享返利加起来不能超过90');
		}
		
		if(empty($this->data['error_messages']['rate']))
		{
			Util::updateSetting(array('return'=>$data));
			
			$this->code = 200;
		}
		else
		{
			$this->code = 500;
		}
	}
}
